import { createSSRApp } from 'vue'
import App from './App.vue'

export function createApp() {
  const app = createSSRApp(App)
  
  // 全局错误处理
  app.config.errorHandler = (err, vm, info) => {
    console.error('Vue Error:', err)
    console.error('Error Info:', info)
    console.error('Component:', vm)
  }
  
  // 全局警告处理
  app.config.warnHandler = (msg, vm, trace) => {
    console.warn('Vue Warning:', msg)
    console.warn('Warning Trace:', trace)
  }
  
  // 添加全局属性
  app.config.globalProperties.$platform = {
    isH5: process.env.VUE_APP_PLATFORM === 'h5',
    isWeixin: process.env.VUE_APP_PLATFORM === 'mp-weixin',
    isApp: process.env.VUE_APP_PLATFORM === 'app-plus'
  }
  
  return {
    app
  }
}
